package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TeachingDesignMapper;
import com.ruoyi.system.domain.TeachingDesign;
import com.ruoyi.system.service.ITeachingDesignService;

/**
 * 教学设计主Service业务层处理
 *
 * @author tyro
 * @date 2025-05-29
 */
@Service
public class TeachingDesignServiceImpl implements ITeachingDesignService
{
    @Autowired
    private TeachingDesignMapper teachingDesignMapper;

    /**
     * 查询教学设计主
     *
     * @param id 教学设计主主键
     * @return 教学设计主
     */
    @Override
    public TeachingDesign selectTeachingDesignById(Long id)
    {
        return teachingDesignMapper.selectTeachingDesignById(id);
    }

    /**
     * 查询教学设计主列表
     *
     * @param teachingDesign 教学设计主
     * @return 教学设计主
     */
    @Override
    public List<TeachingDesign> selectTeachingDesignList(TeachingDesign teachingDesign)
    {
        return teachingDesignMapper.selectTeachingDesignList(teachingDesign);
    }

    /**
     * 新增教学设计主
     *
     * @param teachingDesign 教学设计主
     * @return 结果
     */
    @Override
    public int insertTeachingDesign(TeachingDesign teachingDesign)
    {
        teachingDesign.setCreateTime(DateUtils.getNowDate());
        return teachingDesignMapper.insertTeachingDesign(teachingDesign);
    }

    /**
     * 修改教学设计主
     *
     * @param teachingDesign 教学设计主
     * @return 结果
     */
    @Override
    public int updateTeachingDesign(TeachingDesign teachingDesign)
    {
        teachingDesign.setUpdateTime(DateUtils.getNowDate());
        return teachingDesignMapper.updateTeachingDesign(teachingDesign);
    }

    /**
     * 批量删除教学设计主
     *
     * @param ids 需要删除的教学设计主主键
     * @return 结果
     */
    @Override
    public int deleteTeachingDesignByIds(Long[] ids)
    {
        return teachingDesignMapper.deleteTeachingDesignByIds(ids);
    }

    /**
     * 删除教学设计主信息
     *
     * @param id 教学设计主主键
     * @return 结果
     */
    @Override
    public int deleteTeachingDesignById(Long id)
    {
        return teachingDesignMapper.deleteTeachingDesignById(id);
    }

    @Override
    public Long selectLatestVersionByClassAndTeacher(Long classId, Long teacherId) {
        return teachingDesignMapper.selectLatestVersionByClassAndTeacher(classId, teacherId);
    }

}
